import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

//全局配置
// import "@/assets/scss/reset.scss";
import http from "@/api/config";    //引入aixos实例
import  "./mock";    //引入mock文件

// 引入第三方包 element ui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

// 引入本地组件q-tabs,q-tab-pane
import QTabs from '@/plugins/q-tabs/tabs/index';
import QTabPane from '@/plugins/q-tabs/tab-pane/index';

// 引入本地组件q-form-tabs,q-tab-pane
import QFormTabs from '@/plugins/q-form-tabs/tabs/index';
import QFormTabPane from '@/plugins/q-form-tabs/tab-pane/index';

// 引入vxe-table
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'

// 引入导入导出

import VXETablePluginExportXLSX from 'vxe-table-plugin-export-xlsx'
import VXETablePluginExportPDF from 'vxe-table-plugin-export-pdf'

// 全局配置图标
VXETable.setup({
icon: {
  // table
  TABLE_SORT_ASC: 'vxe-icon--caret-top',
  TABLE_SORT_DESC: 'vxe-icon--caret-bottom',
  TABLE_FILTER_NONE: 'vxe-icon--funnel',
  TABLE_FILTER_MATCH: 'vxe-icon--funnel',
  TABLE_EDIT: 'vxe-icon--edit-outline',
  TABLE_TREE_LOADED: 'vxe-icon--refresh roll',
  TABLE_TREE_OPEN: 'vxe-icon--caret-right rotate90',
  TABLE_TREE_CLOSE: 'vxe-icon--caret-right',
  TABLE_EXPAND_LOADED: 'vxe-icon--refresh roll',
  TABLE_EXPAND_OPEN: 'vxe-icon--arrow-right rotate90',
  TABLE_EXPAND_CLOSE: 'vxe-icon--arrow-right',

  // button
  BUTTON_DROPDOWN: 'vxe-icon--arrow-bottom',
  BUTTON_LOADING: 'vxe-icon--refresh roll',

  // select
  SELECT_OPEN: 'vxe-icon--caret-bottom rotate180',
  SELECT_CLOSE: 'vxe-icon--caret-bottom',

  // pager
  PAGER_JUMP_PREV: 'vxe-icon--d-arrow-left',
  PAGER_JUMP_NEXT: 'vxe-icon--d-arrow-right',
  PAGER_PREV_PAGE: 'vxe-icon--arrow-left',
  PAGER_NEXT_PAGE: 'vxe-icon--arrow-right',
  PAGER_JUMP_MORE: 'vxe-icon--more',

  // input
  INPUT_CLEAR: 'vxe-icon--close',
  INPUT_PWD: 'vxe-icon--eye-slash',
  INPUT_SHOW_PWD: 'vxe-icon--eye',
  INPUT_PREV_NUM: 'vxe-icon--caret-top',
  INPUT_NEXT_NUM: 'vxe-icon--caret-bottom',
  INPUT_DATE: 'vxe-icon--calendar',
  INPUT_SEARCH: 'vxe-icon--search',

  // modal
  MODAL_ZOOM_IN: 'vxe-icon--square',
  MODAL_ZOOM_OUT: 'vxe-icon--zoomout',
  MODAL_CLOSE: 'vxe-icon--close',
  MODAL_INFO: 'vxe-icon--info',
  MODAL_SUCCESS: 'vxe-icon--success',
  MODAL_WARNING: 'vxe-icon--warning',
  MODAL_ERROR: 'vxe-icon--error',
  MODAL_QUESTION: 'vxe-icon--question',
  MODAL_LOADING: 'vxe-icon--refresh roll',

  // toolbar
  TOOLBAR_TOOLS_REFRESH: 'vxe-icon--refresh',
  TOOLBAR_TOOLS_REFRESH_LOADING: 'vxe-icon--refresh roll',
  TOOLBAR_TOOLS_IMPORT: 'vxe-icon--upload',
  TOOLBAR_TOOLS_EXPORT: 'vxe-icon--download',
  TOOLBAR_TOOLS_ZOOM_IN: 'vxe-icon--zoomin',
  TOOLBAR_TOOLS_ZOOM_OUT: 'vxe-icon--zoomout',
  TOOLBAR_TOOLS_CUSTOM: 'vxe-icon--menu',

  // form
  FORM_PREFIX: 'vxe-icon--info',
  FORM_SUFFIX: 'vxe-icon--info',
  FORM_FOLDING: 'vxe-icon--arrow-top rotate180',
  FORM_UNFOLDING: 'vxe-icon--arrow-top'
}
})

// 引入iconfont彩色图标
import '@/api/iconfont.js'

Vue.use(ElementUI);
Vue.use(QTabs);
Vue.use(QTabPane);
Vue.use(QFormTabs);
Vue.use(QFormTabPane);
Vue.use(VXETable);
VXETable.use(VXETablePluginExportXLSX);
VXETable.use(VXETablePluginExportPDF);
Vue.prototype.$XModal = VXETable.modal

Vue.prototype.$http = http;  //aioxs 挂载到vue的原型上
Vue.config.productionTip = false

// 路由拦截 导航守卫
router.beforeEach((to, from, next)=>{
   store.commit('getToken');
   let token = store.state.user.token;
   console.log("token",token);
   if (!token && to.name !== 'login') {
       next({ name: 'login' })
   }else{
      next();  
   }

})

new Vue({
  router,
  store,
  render: h => h(App),
  created() {    //刷新页面防止路由信息掉失
    store.commit('addMenu', router)
  }
}).$mount('#app')
